#ifndef _OCPP_NcSyncFile_H__
#define _OCPP_NcSyncFile_H__

#include "NcVarWrapper.h"

namespace OCPP
{
	using namespace Volume;
	class NcSyncFile {
		using NcSyncFileInstances = std::map<String, std::shared_ptr<NcSyncFile> >;
		using NcDimWrapperCaches = std::map<String, std::shared_ptr<NcDimWrapper> >;
	public:
		CORE_MUTEX(mutex);
		CORE_RW_MUTEX(rw_mutex);

		~NcSyncFile() 
		{
			CORE_LOCK_MUTEX(NcSyncFile::intanceMutex);
			if(!ncFile.isNull())ncFile.close();
		}

		netCDF::NcFile ncFile;
		NcDimWrapperCaches	_dimWrapperCaches;

		FloatVector readFloat(NcVar var);
		FloatVector readFloat(NcVar var, NcReadIndex index);
		IntVector readInt(NcVar var);
		std::shared_ptr<NcDimWrapper> getCacheVar(String name, const VolumeOptions& options);

		static std::mutex intanceMutex;
		static NcSyncFileInstances instances;
	};

}


#endif // !_OCPP_NcOptions_H__
